
require("../less/index.less")
require("../../lib/fonts/iconfont.css")
// require("../../lib/swiper/swiper-bundle.min.js")  
document.ready(function(){
  var mySwiper = new Swiper ('.swiper', {
    autoplay: {
        delay: 2000,
        stopOnLastSlide: false,
        disableOnInteraction: true,
        },
    loop: true, // 循环模式选项
    
    // 如果需要分页器
    pagination: {
      el: '.swiper-pagination',
    },
    
   
  })        

// 发请求拿到当前用户信息
   
   
    
})  
const rankNum = document.querySelector(".rankNum")//排名
console.log(rankNum);
const clockDay = document.querySelector("#clockDay")//累积打卡天数
console.log(clockDay);
const clockBtn = document.querySelector("#clockBtn")//今日打卡
const badgeNum = document.querySelector("#badgeNum")//徽章
let strUser=window.sessionStorage.getItem("user");
let userObj=JSON.parse(strUser);
console.log(userObj);
axios.defaults.headers.authorization =`Bearer ${ userObj.token}`;
axios.get("http://139.9.177.51:3701/api/user/info")
.then((res)=>{
  let result=res.data;
  console.log(result);
  if (result.errno === 0) {
    rankNum.textContent = result.data.ranking;
    badgeNum.textContent = result.data.badges;
    clockDay.textContent = result.data["member.clockCount"];
  }
  else if (result.errno === 10003) {//未登录
    window.$util.toast("zp-close", "请先登录");
    window.setTimeout(() => {
        window.location.href = "./login.html"
    }, 3001)
}
})